//**********************************************************************************
//  PP3_9.java         Author:Tang Caiming
//
//  The random number of the [20-40] interval is generated, and the radius (r)
//  and height of the cylinder are obtained (h).
//**********************************************************************************

import java.util.Random;
import java.text.DecimalFormat;

public class PP3_9
{
   public static void main(String[] args)
   {
      Random generator = new Random();

      int r, h;
      double V, STSA;

      r = generator.nextInt(21) + 20;
      System.out.println("随机产生的圆柱体半径: " + r);

      h = generator.nextInt(21) + 20;
      System.out.println("随机产生的圆柱体高度: " + h);

      V = Math.PI * Math.pow(r, 2) * h;
      STSA = 2 * Math.PI * r * h;

      DecimalFormat fmt = new DecimalFormat("0.####");

      System.out.println("The V of the cylinder: " + fmt.format(V));
      System.out.println("The STSA of the cylinder: " + fmt.format(STSA));
   }
}

